package jsyf.oa.web.system;

import com.alibaba.dubbo.common.utils.StringUtils;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.system.RightOpFacade;
import jsyf.oa.facade.system.Role2DepartFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by jjx on 2018/5/27.
 */
@Api(value = "角色部门接口", description = "角色部门接口")
@Controller
@RequestMapping("/role2Depart")
public class Role2DepartController {

    @Resource
    private Role2DepartFacade role2DepartFacade;


    @RequestMapping(value = "/getTreeNodes.json", method = RequestMethod.POST)
    public void getTreeNodes(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> result = role2DepartFacade.getTreeNodes();
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(result));
    }

    @RequestMapping(value = "/getByRoleNameId.json", method = RequestMethod.POST)
    public void getByRoleNameId(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> result = role2DepartFacade.getByRoleNameId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(result));
    }

    @RequestMapping(value = "/save.json", method = RequestMethod.POST)
    public void save(HttpServletResponse response, @RequestBody String jsonData) {
        Boolean result = role2DepartFacade.save(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(String.valueOf(result)));
    }
}